package com.iot.ammeter.controller.setting;


import com.iot.ammeter.anno.LogAnnotation;
import com.iot.ammeter.responseResult.ResponseResult;
import com.iot.ammeter.service.web.setting.SettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author basil
 * @since 2022-03-10
 */
@Api(tags = {"设置管理"})
@RestController
@RequestMapping("/api/setting")
public class SettingController {

    private final SettingService settingService;

    public SettingController(SettingService settingService) {
        this.settingService = settingService;
    }

    /**
     * 设置电价
     *
     * @return 成功或者失败
     */
    @ApiOperation(value = "设置电价")
    @LogAnnotation(module = "SettingController", operator = "设置电价")
    @PostMapping("/electricity_prices")
    public ResponseResult setElectricityPrices(@RequestBody String price) {
        return settingService.setElectricityPrices(price) ? ResponseResult.SUCCESS("设置电价成功。") : ResponseResult.FAILED("设置电价失败。");
    }
}
